package com.epam.cdp.jpa.dao;

import javax.ejb.Stateless;
import javax.persistence.Query;

import com.epam.cdp.jpa.model.User;

@Stateless
public class UserDAO extends AbstractStatelessDAO<User> {

    @Override
    public Class<User> getEntityClass() {
	return User.class;
    }

    public User getByEmail(String email) {
	Query query = getEntityManager().createQuery("SELECT u FROM User u WHERE u.email = :e", User.class);
	query.setParameter("e", email);
	return (User) query.getResultList().get(0);
    }
    
}
